package workers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import messaging.IMessagingHandler;
import messaging.JMSMessagingConstants;
import messaging.SoftwareDevelopmentMessagingHandler;
import model.Software;
import workerUIs.StepFrame;
import workflow.step.ImplementationStep;

public class ImplementationStepWorker extends AbstractStepSwingWorker {


	public ImplementationStepWorker(StepFrame frame, IMessagingHandler<Software> messagingHandler) {
		super(frame, messagingHandler);
	}

	@Override
	protected void doStep(Software software) {
		new ImplementationStep().doStep(this.software);		
	}
	
	public static void main(String[] args)
	{
		Logger logger = Logger.getLogger(ArchitectureStepWorker.class.getCanonicalName());		
		try {
			final StepFrame implementationFrame = new StepFrame("Step3a: Implementation", 800,0);
			List<String> implInputQueues = new ArrayList<String>();
			implInputQueues.add(JMSMessagingConstants.ARCH_OUTPUT_IMPL_INPUT);
			List<String> implOutputQueues = new ArrayList<String>();
			implOutputQueues.add(JMSMessagingConstants.IMPL_OUTPUT_INTEGRATION_INPUT);
			final IMessagingHandler<Software> messagingHandler = new SoftwareDevelopmentMessagingHandler(implementationFrame, implInputQueues, implOutputQueues);
			implementationFrame.getNextButton().addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					new ImplementationStepWorker(implementationFrame, messagingHandler).execute();				
				}
			});
			
		}
		catch (Exception e)
		{
			logger.log(Level.SEVERE, "Error during initialization: ", e);
		}
	}

}
